
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:logger/logger.dart';

class AppUtil{
  static bool isLargeScreen(context){
    bool isLargeScreen = MediaQuery.of(context).size.width > 600;
    return isLargeScreen;
  }

}

class AppTimeUtils{
  static String formatSeconds(int seconds) {
    int hours = seconds ~/ 3600;
    int minutes = (seconds ~/ 60) % 60;
    int secs = seconds % 60;

    String hoursStr = hours.toString().padLeft(2, '0');
    String minutesStr = minutes.toString().padLeft(2, '0');
    String secsStr = secs.toString().padLeft(2, '0');

    return '$hoursStr:$minutesStr:$secsStr';
  }

  static (String,String) getSimpleOfTime(String dateStr){
    // var date = DateTime.fromMillisecondsSinceEpoch(int.parse(dateStr));
    var date = DateTime.parse(dateStr);
    // var date = DateTime.now().add(Duration(days: 3,seconds: 10));
    DateTime now = DateTime.now();
    DateTime now_0 = DateTime(now.year,now.month,now.day);
    var diffTime = date.difference(now_0);
    var days = diffTime.inDays;
    var hmStr = DateFormat.Hm().format(date);
    switch(days){
      case 0:
        return ("今天",hmStr);
        case 1:
        return ("明天",hmStr);
      case 2:
        return ("后天",hmStr);

    }
    var ms = int.tryParse(dateStr);
    if(ms != null){
      return (DateUtil.formatDateMs(ms,format: DateFormats.y_mo_d),hmStr);
    }else{
      return (DateUtil.formatDateStr(dateStr,format: DateFormats.mo_d),hmStr);
    }
    return (dateStr,hmStr);
  }

  static String getYMDHm(dynamic dateStr){
    if(dateStr == null){
      return "";
    }
    var ms = int.tryParse(dateStr.toString());
    if(ms != null){
      return DateUtil.formatDateMs(ms,format: DateFormats.y_mo_d_h_m);
    }
    return dateStr.toString();
  }
  static String getHm(dynamic dateStr){
    if(dateStr == null){
      return "";
    }
    var ms = int.tryParse(dateStr.toString());
    if(ms != null){
      return DateUtil.formatDateMs(ms,format: DateFormats.y_mo_d_h_m);
    }
    return dateStr.toString();
  }
}

